// https://umijs.org/config/
import { defineConfig } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  history:{type:'hash'},
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    antd: true,
    // default true, when it is true, will use `navigator.language` overwrite default
    baseNavigator: true,
  },
  dynamicImport: {
    loading: '@/components/PageLoading/index',
  },
  targets: {
    ie: 11,
  },
  // umi routes: https://umijs.org/docs/routing
  routes: [
    {
      path: '/user',
      component: '../layouts/UserLayout',
      routes: [
        {
          name: 'login',
          path: '/user/login',
          component: './user/login',
        },
      ],
    },
    {
      path: '/',
      component: '../layouts/SecurityLayout',
      routes: [
        {
          path: '/',
          component: '../layouts/BasicLayout',
          authority: ['admin', 'user'],
          routes: [
            {
              path: '/',
              redirect: '/welcome',
            },
            {
              path: '/welcome',
              name: '首页',
              icon: 'home',
              component: './Welcome',
            },{
              path: '/dashbord',
              name: '工作台',
              icon: 'bar-chart',
              component: './Dashbord',
              authority:['provinceUser','cityUser','provinceLeader','cityLeader'],
            },
            {
              name: '创新工作室',
              icon: 'crown',
              path: '/studio',
              authority:['provinceUser','cityUser','provinceLeader','cityLeader'],
              routes:[
                {
                  name: '工作室列表',
                  path: '/studio/list',
                  component: './InnovationStudio/apply/StudioList',
                },
                {
                  name: '工作室审批',
                  path: '/studio/review',
                  component: './InnovationStudio/review',
                }
              ]
            },
            {
              name: '创新项目',
              icon: 'table',
              path: '/project/innovation',
              authority:['provinceUser','cityUser','provinceLeader','cityLeader'],
              routes:[
                {
                  name: '项目列表',
                  path: '/project/innovation/apply',
                  component: './InnovationProject/apply/ProjectList',
                },
                {
                  name: '项目执行',
                  path: '/project/innovation/execution',
                  component: './InnovationProject/execution',
                },
                {
                  name: '项目审批',
                  path: '/project/innovation/review',
                  component: './InnovationProject/review',
                },                
                {
                  name: '成果评定',
                  path: '/project/innovation/result/evaluation',
                  component: './InnovationProject/ResultEvaluation',
                }
              ]
              
            },
            {
              name: 'QC课题',
              icon: 'phone',
              path: '/project/qc_project',
              authority:['provinceUser','cityUser','provinceLeader','cityLeader'],
              routes:[
                {
                  name: '课题列表',
                  path: '/project/qc_project/apply',
                  component: './QCproject/apply/ProjectList',
                },
                {
                  name: '课题审批',
                  path: '/project/qc_project/review',
                  component: './QCproject/review',
                },
                {
                  name: '活动管理',
                  path: '/project/qc_project/execution',
                  component: './QCproject/execution',
                },
                {
                  name: '成果评价',
                  path: '/project/qc_project/result/evaluation',
                  component: './QCproject/ResultEvaluation',
                }
              ]
              
            },
            {
              name: '精益项目',
              icon: 'gold',
              path: '/project/lean_project',
              authority:['provinceUser','cityUser','provinceLeader','cityLeader'],
              routes:[
                {
                  name: '项目列表',
                  path: '/project/lean_project/apply',
                  component: './LeanProject/apply/ProjectList',
                },
                {
                  name: '项目审批',
                  path: '/project/lean_project/review',
                  component: './LeanProject/review',
                },                
                {
                  name: '成果评定',
                  path: '/project/lean_project/result/evaluation',
                  component: './LeanProject/ResultEvaluation',
                }
              ]
            },
            {
              name: '悬赏任务',
              icon: 'dollar',
              path: '/project/offered_project',
              authority:['provinceUser','cityUser','provinceLeader','cityLeader'],
              routes:[
                {
                  name: '任务管理',
                  path: '/project/offered_project/apply',
                  component: './offeredProject/apply/ProjectList',
                },
                {
                  name: '任务审批',
                  path: '/project/offered_project/review',
                  component: './offeredProject/review/ProjectList',
                },
                {
                  name: '项目执行',
                  path: '/project/offered_project/execution',
                  component: './offeredProject/execution',
                },
              ]
            },
            {
              name: '人员管理',
              icon: 'user',
              path: '/user_info/list',
              authority: ['admin'],
              component: './UserInfo/UserList',
            },{
              name: '系统设置',
              icon: 'setting',
              path: '/system',
              authority: ['admin'],
              routes:[
                {
                  name: '部门管理',
                  path: '/system/department',
                  authority: ['admin'],
                  component: './System/Department',
                }
              ]
            },
            {
              component: './404',
            },
          ],
        },
        {
          component: './404',
        },
      ],
    },
    {
      component: './404',
    },
  ],
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  proxy: proxy[REACT_APP_ENV || 'dev'],
  manifest: {
    basePath: '/',
  },
});
